<template>
  <div>
    <el-input
      v-model="tempSearchObj.username"
      placeholder="用户名"
      style="width: 200px; margin-right: 10px"
    ></el-input>
    <el-button type="primary" icon="el-icon-search">查询</el-button>
    <el-button>清空</el-button>
    <div style="margin: 20px">
      <el-button type="primary">添加</el-button>
      <el-button type="danger">批量删除</el-button>
    </div>

    <el-table border stripe>
      <!-- @selection-change="handleSelectionChange" -->
      <el-table-column type="selection" width="55"> </el-table-column>
      <el-table-column
        type="index"
        label="序号"
        width="80"
        align="center"
      ></el-table-column>
      <el-table-column prop="name" label="用户名" width="120" align="center">
      </el-table-column>
      <el-table-column
        prop="name"
        label="用户昵称"
        align="center"
      ></el-table-column>
      <el-table-column prop="name" label="权限列表"></el-table-column>
      <el-table-column
        prop="name"
        label="创建时间"
        width="180"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="name"
        label="更新时间"
        width="180"
        align="center"
      ></el-table-column>
      <el-table-column prop="name" label="操作"></el-table-column>
    </el-table>
    <!-- @current-change="getUsers"
      @size-change="handleSizeChange" -->
    <el-pagination
      :current-page="1"
      :total="99"
      :page-size="4"
      :page-sizes="[3, 10, 20, 30, 40, 50, 100]"
      style="padding: 20px 0"
      layout="prev, pager, next, jumper, ->, sizes, total"
    />
    <!-- 修改或添加用户 -->
    <el-dialog title="修改用户" :visible.sync="dialogFormVisible">
      <el-form :model="form" label-width="120px">
        <el-form-item label="用户名">
          <el-input></el-input>
        </el-form-item>
        <el-form-item label="用户昵称" :label-width="formLabelWidth">
          <el-input></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button>取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 设置角色 -->
    <el-dialog title="设置角色" :visible.sync="dialogFormVisible">
      <el-form label-width="80px">
        <el-form-item label="用户名">
          <el-input disabled></el-input>
        </el-form-item>
        <el-form-item label="角色列表">
          <el-checkbox
            :indeterminate="isIndeterminate"
            v-model="checkAll"
            @change="handleCheckAllChange"
            >全选</el-checkbox
          >
          <div style="margin: 15px 0"></div>
          <el-checkbox-group
            v-model="userRoleIds"
            @change="handleCheckedChange"
          >
            <el-checkbox
              v-for="role in allRoles"
              :key="role.id"
              :label="role.id"
              >{{ role.roleName }}</el-checkbox
            >
          </el-checkbox-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button>取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "User",
  data() {
    return {
      searchObj: {
        // 包含请求搜索条件数据的对象
        username: "",
      },
      tempSearchObj: {
        // 收集搜索条件输入的对象
        username: "",
      },
      dialogTableVisible: false,
      dialogFormVisible: fals,
      form: {
        name: "",
        region: "",
      },
      formLabelWidth: "120px",
    };
  },
  mounted() {
      this.getUsers()
  },
  methods: {
    //获取分页
    async getUsers(page=1){
        this.page = page
        const{limit,searchObj} = this
        const result = await this.$ajax.user.getPageList(page,limit,searchObj)
        console.log(result)
    }
  },
};
</script>

<style>
</style>